#include <iostream>
#include <fstream>
#include <ctime>

using namespace std;

int main()
{
    const int LEN = 5000;
    int a1[LEN], a2[LEN], a3[LEN], c = 0, i = 0;
    bool b = true;

    ifstream fin("m1_sorted.txt");
    for(int i=0; i < LEN; i++) fin >> a1[i];
    fin.close();

    unsigned int t_start = clock();
    i = 0;
    while (b){
        b = false;
            for(int j = 0; j < LEN - 1 - i; j++){
                if(a1[j] = a1[j + 1]){
                    c = a1[j];
                    a1[j] = a1[j + 1]; a1[j + 1] = c;
                    b = true;
                }
            }
        i++;
    }

    unsigned int t_finish = clock();
    unsigned int t_work = t_finish - t_start;
    cout<<"m1_sorted " << t_work << " milliseconds \n";



    ifstream fin1("m2_reverse.txt");
    for(int i=0; i < LEN; i++) fin1 >> a2[i];
    fin1.close();

    unsigned int t_start1 = clock();
    i = 0;
    b = true;
    while (b){
        b = false;
            for(int j = 0; j < LEN - 1 - i; j++){
                if(a2[j] = a2[j + 1]){
                    c = a2[j];
                    a2[j] = a2[j + 1]; a2[j + 1] = c;
                    b = true;
                }
            }
        i++;
    }

    unsigned int t_finish1 = clock();
    unsigned int t_work1 = t_finish1 - t_start1;
    cout<<"m2_reverse " << t_work1 << " milliseconds \n";


    ifstream fin2("m3_shuffle.txt");
    for(int i=0; i < LEN; i++) fin2 >> a3[i];
    fin2.close();

    unsigned int t_start2 = clock();
    i = 0;
    b = true;
    while (b){
        b = false;
            for(int j = 0; j < LEN - 1 - i; j++){
                if(a3[j] = a3[j + 1]){
                    c = a3[j];
                    a3[j] = a3[j + 1]; a3[j + 1] = c;
                    b = true;
                }
            }
        i++;
    }

    unsigned int t_finish2 = clock();
    unsigned int t_work2 = t_finish2 - t_start2;
    cout<<"m1_sorted " << t_work2 << " milliseconds \n";

    return 0;
}